package main

import (
	"fmt"
	"strconv"

)
type Element interface{}
type List []Element
type Person struct {
	name string
	age int
}

func (p Person) String() string{
	return "(name:"+p.name+" age:"+strconv.Itoa(p.age)+")"
}
func main()  {
	//示列1
	var a interface{}
	var i int = 100
	s := "hell xiaoming"
	a = i
	fmt.Println(a)
	a = s
	fmt.Println(a)
	//实例2
	list := make(List,3)
	list[0] = 1
	list[1] = "hello"
	list[2] = Person{"zhangsan",1}

	for i,e :=range list{
		switch value := e.(type){
		case int:
			fmt.Printf("List [%d] is an int and its value is %d \n",i,value)
		case string:
			fmt.Printf("List [%d] is an int and its value is %s \n",i,value)
		case Person:
			fmt.Printf("list [%d] is a person and its value is %s \n",i,value)
		default:
			fmt.Printf(" list [%d] is of a different type",i)

		}
	}



}